<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
	public function index(){
        //banner:
		$banner=M('banner');
    	$bannerlist=$banner->select();
    	$this->assign('bannerlist',$bannerlist);
        //项目展示：
        $project=M('project');
        $UIprojectlist=$project->where("type=1")->select();
        $HTML5projectlist=$project->where("type=2")->select();
        $this->assign("UIprojectlist",$UIprojectlist);
        $this->assign("HTML5projectlist",$HTML5projectlist);
        //新闻展示：
        $news=M('newsinfo');
        $newsData=$news->where('type=3')->order('newsDate desc')->limit(2)->select();
        $this->assign('newsData',$newsData);
       
        // 荣誉添加
      
        $join=M('join');
        $ronnu=$join->where("content")->select();
        $wdat=$join->where("wdate")->select();
        //var_dump($ronnu);
        $this->assign("ronnu",$ronnu);
        $this->assign("wdat",$wdat);
        $this->display();
    }
    
    public function login(){
    	$this->display();
	}

	public function account(){
    $user['name']=I('post.name');//$_POST['username'];I方法接收数据（安全问题）
    $user['password']=I('post.password');//$_POST['password'];
    $list=M('account');
    $result=$list->where($user)->select();
    // var_dump($result);
        if(count($result)>0){
            //登录成功后跳转后台页面
            //设置登录状态
            $result[0]['name']=html_entity_decode($result[0]['name']);//将i方法接收的html字符串转换成html代码
            cookie('name',$result[0]['name'],3600);
            $this->success('登录成功', U('Index/index'));
        } else {
            //错误返回登录页
            $this->error('登录失败');
        }
    }

    public function loginOut(){
        // 退出登录
        cookie('name',null);
        $this->success('退出成功', U('Login/index'));
    }


}
